/*
+--------------------------------------------------------------------------
|   Mblog [#RELEASE_VERSION#]
|   ========================================
|   Copyright (c) 2014, 2015 mtons. All Rights Reserved
|   http://www.mtons.com
|
+---------------------------------------------------------------------------
*/
package com.monkey.utils.upload;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @author langhsu
 */
public interface FileService {
    /**
     * 保存临时文件
     * - 临时文件不会生成复杂的多级目录
     *
     * @param file
     * @param basePath
     * @return
     * @throws java.io.IOException
     */
    String temp(MultipartFile file, String basePath) throws IOException;

    /**
     * 存储文件
     *
     * @param file
     * @param basePath
     * @return
     * @throws java.io.IOException
     */
    String store(MultipartFile file, String basePath) throws IOException;

    /**
     * 存储文件
     *
     * @param file
     * @param basePath
     * @return
     * @throws java.io.IOException
     */
    String store(File file, String basePath) throws IOException;

    /**
     * 从tempPath 转换文件到 basePath文件
     *
     * @param tempFilePath
     * @param basePath
     * @return
     * @throws IOException
     */
    String store(String tempFilePath, String basePath) throws IOException;

    String getRoot();

    /**
     * 存储路径
     *
     * @param storePath
     */
    void deleteFile(String storePath);

    /**
     * 文件类型判断
     *
     * @param fileName
     * @return
     */
    boolean checkFileType(String fileName, List<String> allowFiles);
}
